package xiaohu.day2.HJ26;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            char[] chars = in.nextLine().toCharArray();
            ArrayList<Character> arrayList = new ArrayList<>();
            HashMap<Integer, Character> hashMap = new HashMap<>();
            //将字母存入array List中、非字母存入hashMap中
            for (int i = 0; i < chars.length; i++) {
                if (chars[i] >= 'a' && chars[i] <= 'z' || chars[i] >= 'A' && chars[i] <= 'Z') {
                    arrayList.add(chars[i]);
                } else {
                    hashMap.put(i, chars[i]);
                }
            }
            //排序是否稳定
            arrayList.sort(new Comparator<Character>() {
                @Override
                public int compare(Character o1, Character o2) {
                    return Character.toLowerCase(o1) -Character.toLowerCase(o2);
                }
            });
            //插入非字母
            StringBuilder stringBuilder = new StringBuilder();
            int index=0;
            for (int i = 0; i < arrayList.size(); i++,index++) {
                while (hashMap.containsKey(index)) {
                    stringBuilder.append(hashMap.get(index));
                    index++;
                }
                stringBuilder.append(arrayList.get(i));
            }
            //添加剩余的非字母
            while (hashMap.containsKey(index)) {
                stringBuilder.append(hashMap.get(index));
                index++;
            }
            System.out.println(stringBuilder);
        }
    }
}
